package month4.day26;

import java.io.FileInputStream;
import java.io.InputStream;

public class S4 {
    private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

    public static void main(String[] args) {
        InputStream in = null;
        try {
            in = new FileInputStream("D:\\Pictures\\无标题.png");
            byte[] b = new byte[8];

            char[] buf = new char[b.length * 2];
            int a = 0;
            int index = 0;
            for(byte b1 : b) { // 使用除与取余进行转换
                if(b1 < 0) {
                    a = 256 + b1;
                } else {
                    a = b1;
                }

                buf[index++] = HEX_CHAR[a / 16];
                buf[index++] = HEX_CHAR[a % 16];
            }
            String bf=new String(buf);
            System.out.println(bf.toString());
            in.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
